package com.javaziliao.design.bridge.abst;

import com.javaziliao.design.bridge.function.IRegisterLoginFunc;
import com.javaziliao.design.pojo.UserInfo;

import javax.servlet.http.HttpServletRequest;

public abstract class AbstractRegisterLoginComponent {

    protected IRegisterLoginFunc funcInterface;

    public AbstractRegisterLoginComponent(IRegisterLoginFunc funcInterface) {
        validate(funcInterface);
        this.funcInterface = funcInterface;
    }

    protected final void validate(IRegisterLoginFunc funcInterface) {
        if (funcInterface == null) {
            throw new UnsupportedOperationException("未知的注册登录方式！");
        }
    }

    public abstract String login(String username, String password);

    public abstract String register(UserInfo userInfo);

    public abstract boolean checkUserExists(String userName);

    public abstract String login3rd(HttpServletRequest request);
}
